<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class StoreChannelPostRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $arr_Cooperation = array_keys(config('cooperation'));
        $arr_Target = array_keys(config('cooperation-target'));
        $arr_ContactType = array_keys(config('contract-type'));
        return [
            'channel_provider_id' => 'required|exists:channel_providers,id',
            'code' => 'required|string|between:2,10',
            'no' => 'required|numeric|multi_unique:code,channels,no,code',
            'cooperation' => 'required|in:' . implode(',',$arr_Cooperation),
            'target' => 'required|in:' . implode(',',$arr_Target),
            'start_date' => 'required|date',
            'end_date' => 'required|date',
            'contract_type' => 'required|in:' . implode(',',$arr_ContactType),
            'contract_amount' => 'required|numeric|min:1',
            'expections' => 'string'
        ];
    }
}
